<template>
	<view class="mine">
		<view class="userInfo">
			<view class="userInfoLeft" @click="handleUserInfo">
				<image v-if="pageData.avatar == null" src="../../static/image/avatar.jpg" mode=""
					style="width: 128rpx; height: 128rpx; border-radius: 128rpx;border: 4rpx solid #FFFFFF;;"></image>
				<image v-else :src="pageData.avatar" mode=""
					style="width: 128rpx; height: 128rpx; border-radius: 128rpx;border: 4rpx solid #FFFFFF;;"></image>
				<view class="message">
					<view class="name">
						<view class="text">
							{{pageData.nickname}}
						</view>
						<image src="../../static/image/bianji.png" mode=""
							style="width: 30rpx;height: 30rpx;margin-left: 16rpx;"></image>
					</view>
					<!-- <view class="cont">
						<image src="../../static/image/sex.png" mode="" style="width: 50rpx;height: 30rpx;"></image>
						<view class="contright">
							<image src="../../static/image/date.png" mode="" style="width: 34rpx;height: 30rpx;">
							</image>
							<view class="date">
								10月19日
							</view>
						</view>
					</view> -->
					<view class="phone" style="margin-top: 20rpx;">
						<image src="../../static/image/phome.png" mode="" style="width: 50rpx;height: 30rpx;"></image>
						<view class="text">
							{{pageData.username}}
						</view>
					</view>

				</view>
			</view>
			<!-- <image src="../../static/image/smrz.png" mode="" style="width: 200rpx; height: 56rpx; ;" @click="handleSm">
			</image> -->
		</view>
		<view class="typeList">
			<view class="typeitem" @click="handleSm">
				<view class="typeleft">
					<image src="../../static/image/sksz.png" mode="" style="width: 36rpx;height: 36rpx;"></image>
					<view class="lefttext">
						收款设置
					</view>
				</view>
				<image src="../../static/image/right.png" mode="" style="width: 16rpx;height: 28rpx;"></image>
			</view>

			<view class="typeitem" @click="handleHelpcenter">
				<view class="typeleft">
					<image src="../../static/image/bzzx.png" mode="" style="width: 36rpx;height: 36rpx;"></image>
					<view class="lefttext">
						帮助中心
					</view>
				</view>
				<image src="../../static/image/right.png" mode="" style="width: 16rpx;height: 28rpx;"></image>
			</view>
			<view class="typeitem" @click="handleSyetem">
				<view class="typeleft">
					<image src="../../static/image/xtsz.png" mode="" style="width: 36rpx;height: 36rpx;"></image>
					<view class="lefttext">
						系统设置
					</view>
				</view>
				<image src="../../static/image/right.png" mode="" style="width: 16rpx;height: 28rpx;"></image>
			</view>

			<view class="typeitem" @click="mySy">
				<view class="typeleft">
					<u-icon name="rmb-circle-fill" color="#333333" size="21"></u-icon>
					<view class="lefttext">
						我的收益
					</view>
				</view>
				<image src="../../static/image/right.png" mode="" style="width: 16rpx;height: 28rpx;"></image>
			</view>

		</view>

		<view class="btns" @click="handleEitd">
			退出登录
		</view>


	</view>
</template>

<script>
	import {
		userinfo
	} from "@/api/api.js"
	export default {
		data() {
			return {
				pageData: {},
			}
		},
		onLoad() {
			if (!uni.getStorageSync("token")) {
				uni.reLaunch({
					url: "../login/index"
				})
				return
			}
		},
		onShow() {
			this.handleGetuserinfo()
		},
		methods: {
			mySy() {
				uni.navigateTo({
					url: "./mySy"
				})
			},
			async handleGetuserinfo() {
				let res = await userinfo()
				this.pageData = res.data

				this.pageData.username = this.pageData.username.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
				console.log("用户信息", res)
			},
			handleUserInfo() {
				uni.navigateTo({
					url: "./userInfo"
				})
			},
			handleEitd() {
				uni.showModal({
					content: '您确定要退出登录吗？',
					confirmColor: "#04767C",
					success: function() {
						console.log("pppppppppppppppppp")
						uni.removeStorageSync("token")
						uni.reLaunch({
							url: "/pages/login/index"
						})
					}
				});

			},

			handleSm() {
				uni.navigateTo({
					url: "../home/authentication"
				})
			},

			handleSk() {
				uni.navigateTo({
					url: "./collection"
				})
			},
			handleFeedback() {
				uni.navigateTo({
					url: "./feedback"
				})
			},
			handleHelpcenter() {
				uni.navigateTo({
					url: "./helpCenter"
				})
			},
			handleAboutus() {
				uni.navigateTo({
					url: "./aboutUs"
				})
			},
			handleSyetem() {
				uni.navigateTo({
					url: "./system"
				})
			}


		}
	}
</script>

<style scoped lang="scss">
	.btns {
		width: 542rpx;
		height: 80rpx;
		background: #04767C;
		border-radius: 512rpx 512rpx 512rpx 512rpx;
		text-align: center;
		font-size: 36rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		margin: 0 auto;
		margin-top: 198rpx;
		line-height: 80rpx;
	}

	.mine {
		.userInfo {
			width: 100%;
			height: 150rpx;
			padding: 30rpx;
			padding-right: 0;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.userInfoLeft {
				display: flex;
				align-items: center;
			}

			.message {
				margin-left: 22rpx;


				.name {
					display: flex;
					align-items: center;
					font-size: 36rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: 400;
					color: #333333;
					line-height: 34rpx;
				}

				.cont {
					display: flex;
					margin: 20rpx 0;

					.contright {
						display: flex;
						margin-left: 8rpx;
						align-items: center;
						height: 30rpx;
						border-radius: 0rpx 2rpx 2rpx 0rpx;
						opacity: 1;
						border: 2rpx solid #359691;
						font-size: 20rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 400;
						color: #359691;
						line-height: 30rpx;
					}
				}

				.phone {
					display: flex;
					height: 28rpx;
					font-size: 20rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					color: #359691;
					line-height: 28rpx;
					border: 2rpx solid #359691;
				}
			}
		}

		.typeList {
			margin-top: 40rpx;

			.typeitem {
				width: 100%;
				height: 76rpx;
				background: #FFFFFF;
				display: flex;
				padding: 20rpx 30rpx;
				box-sizing: border-box;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 16rpx;

				.typeleft {
					display: flex;
					align-items: center;

					.lefttext {
						font-size: 28rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 400;
						color: #333333;
						line-height: 40rpx;
						margin-left: 66rpx;
					}
				}
			}
		}

	}
</style>